function TREEsearch(e) {
	let reg = new RegExp(e.value, 'i')
	console.log(reg)
	document.querySelectorAll('#TREE_1_ul li').forEach(i => {
		reg.test(i.innerText) ? i.style.display = 'list-item' : i.style.display = 'none'
	})
	var treeObj = $.fn.zTree.getZTreeObj("TREE");
	treeObj.expandAll(true);


}
function Tsearch(e){
	let reg = new RegExp(e.value, 'i')
	console.log(reg)
	document.querySelectorAll('ul#toc-in li').forEach(i => {
		reg.test(i.innerText) ? i.style.display = 'list-item' : i.style.display = 'none'
	})
	
}
(function(){
	window.ScrollToControl= function (elem=null) {
		if(elem){
			
		}else{
			toWhere(0)
		}
	}
	function toWhere(position){
		let height = getScrollTop()
		window.scrollTo(0,position)
		console.log('滚动完成')
		
	}
	function getScrollTop(){
		var scrollTop=0;
		if(document.documentElement&&document.documentElement.scrollTop){
		scrollTop=document.documentElement.scrollTop;
		}else if(document.body){
		scrollTop=document.body.scrollTop;
		}
		return scrollTop;
	}
	
})()

function showSideBar(id){
	if(document.getElementById(id).style.display=='block'){
		document.getElementById('sidebar').classList.toggle('hide');
	}
	
	document.getElementById(id).style.display='block';
	document.querySelectorAll(`#sidebar > div`).forEach(i=>{
		if(i.id!==id){
			i.style.display='none'
		}
	})
}
function toTitle(e){
	console.log(e.target.href)
	e.preventDefault()
	document.getElementById(e.target.dataset.id).scrollIntoViewIfNeeded()
	

}